import React,{useState} from "react";
import { Form, Input, Button, Select, InputNumber, Spin,message } from "antd";
import { userRole } from "../../api/user";
import { $http,request } from "../../utils/request";
const layout = {
  labelCol: {
    span: 4,
  },
  wrapperCol: {
    span: 16,
  },
};
const tailLayout = {
  wrapperCol: {
    offset: 8,
    span: 16,
  },
};

const RoleManager = () => {
  const [form] = Form.useForm();
  let [loading,setLoading] = useState(false)

  const onFinish = (values) => { //表单提交
    console.log(values);
    setLoading(true)
    userRole(values).then(res=>{
      setLoading(false)
    })
  };

  const onReset = () => { //重置表单
    form.resetFields();
  };

  return (
    <Spin spinning={loading}>
      <Form {...layout} form={form} name="control-hooks" onFinish={onFinish}>
        <Form.Item
          name="rolename"
          label="角色名称"
          rules={[
            {
              required: true,
            },
          ]}
        >
          <Input />
        </Form.Item>
        <Form.Item
          name="rolecode"
          label="角色代号"
          rules={[
            {
              required: true,
            },
          ]}
        >
          <Input />
        </Form.Item>
        <Form.Item {...tailLayout}>
          <Button type="primary" htmlType="submit">
            发布
          </Button>
          <Button htmlType="button" onClick={onReset}>
            重置
          </Button>
          {/* <Button type="primary" ghost onClick={handleCfy}>
            转存
          </Button> */}
        </Form.Item>
      </Form>
    </Spin>
  );
};

export default RoleManager;
